<?php
/**
 * Remove a Partner From a Mission
 */

use Hive\Mission;
$missionid = Xview::instance()->val("missionid");
$partnerid = Xview::instance()->val("ressource_id"); 
var_dump($partnerid);
if(!empty($partnerid) && !empty($missionid))
{
	try {
		$mission = new Mission($missionid);
		$partner = $mission->partner($partnerid);
		$partner->delete();
		Fox\Message::Success(Msg(Hive::BUNDLE,31,$partner->source()->name(),$mission->label()));
	}
	catch(Fox\Object\Exception\Save $e)
	{
		Fox\Message::Error($e->getMessage());
	}
}

$block = Xview::instance()->component("missions","ressources");
$grid = $block->item("gRessources");
$customers = $mission->partnersSourceObjects();
$grid->setDatas($customers);
echo $block->display();